package org.soenea.doitall.domain.model.invite.mapper;

import java.sql.SQLException;
import org.dsrg.soenea.domain.MapperException;
import org.dsrg.soenea.domain.mapper.DomainObjectNotFoundException;
import org.dsrg.soenea.domain.mapper.IOutputMapper;
import org.dsrg.soenea.domain.mapper.LostUpdateException;
import org.soenea.doitall.domain.model.invite.data.*;
import org.soenea.doitall.domain.model.invite.*;

public class InviteOutputMapper implements IOutputMapper<Long, Invite> {
	public void update(Invite invite) throws MapperException,DomainObjectNotFoundException {
		try {
			int count = InviteTDG.update(invite.getId(),invite.getStatus(),invite.getVersion());
			if (count == 0)
				throw new LostUpdateException("Invite " + invite.getId() + " has already been updated.");			 
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void insert(Invite invite) throws MapperException {
		try {
			InviteTDG.insert(invite.getId(), invite.getInviter().getId(), invite.getInvited().getId(), invite.getGroupID().getId());
		} catch (SQLException e) {
			throw new MapperException(e);
		}
		
	}

	@Override
	public void delete(Invite d) throws MapperException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void cascadeInsert(Invite d) throws MapperException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void cascadeUpdate(Invite d) throws MapperException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void cascadeDelete(Invite d) throws MapperException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void validateInsert(Invite d) throws MapperException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void validateUpdate(Invite d) throws MapperException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void validateDelete(Invite d) throws MapperException {
		// TODO Auto-generated method stub
		
	}
}
